package com.ithuameng.admin.enums;

import javax.servlet.http.HttpServletResponse;

/**
 * 状态返回信息
 *
 * @author ithuameng
 */
public enum CommonError implements BaseError {

    /**
     * 200
     */
    OK(HttpServletResponse.SC_OK, "OK"),

    /**
     * 400
     */
    BAD_REQUEST(HttpServletResponse.SC_BAD_REQUEST, "请求参数错误或不完整"),

    /**
     * 401
     */
    UNAUTHORIZED(HttpServletResponse.SC_UNAUTHORIZED, "请先进行认证"),

    /**
     * 403
     */
    FORBIDDEN(HttpServletResponse.SC_FORBIDDEN, "无权查看"),

    /**
     * 404
     */
    NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "未找到该路径"),

    /**
     * 405
     */
    METHOD_NOT_ALLOWED(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "请求方式不支持"),

    /**
     * 406
     */
    NOT_ACCEPTABLE(HttpServletResponse.SC_NOT_ACCEPTABLE, "不可接受该请求"),

    /**
     * 411
     */
    LENGTH_REQUIRED(HttpServletResponse.SC_LENGTH_REQUIRED, "长度受限制"),

    /**
     * 415
     */
    UNSUPPORTED_MEDIA_TYPE(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "不支持的媒体类型"),

    /**
     * 416
     */
    REQUESTED_RANGE_NOT_SATISFIABLE(HttpServletResponse.SC_REQUESTED_RANGE_NOT_SATISFIABLE, "不能满足请求的范围"),

    /**
     * 500
     */
    INTERNAL_SERVER_ERROR(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "服务器正在升级，请耐心等待"),

    /**
     * 503
     */
    SERVICE_UNAVAILABLE(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "请求超时"),

    // ----------------------------------------------------业务异常----------------------------------------------------
    /**
     * 演示系统，无法该操作
     */
    DEMO_SYSTEM_CANNOT_DO(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "演示系统，无法该操作"),

    /**
     * JSON格式错误
     */
    JSON_FORMAT_ERROR(HttpServletResponse.SC_BAD_REQUEST, "JSON格式错误"),

    /**
     * 用户名密码错误
     */
    USERNAME_OR_PASSWORD_IS_WRONG(HttpServletResponse.SC_BAD_REQUEST, "用户名密码错误"),

    /**
     * 用户被禁用
     */
    USER_IS_DISABLED(HttpServletResponse.SC_NOT_ACCEPTABLE, "用户被禁用"),

    /**
     * 未找到该用户
     */
    USER_NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "未找到该用户"),

    /**
     * 原密码不正确
     */
    ORIGINAL_PASSWORD_IS_INCORRECT(HttpServletResponse.SC_BAD_REQUEST, "原密码不正确"),

    /**
     * 用户名已存在
     */
    USERNAME_ALREADY_EXISTS(HttpServletResponse.SC_BAD_REQUEST, "用户名已存在"),

    /**
     * 未找到该菜单
     */
    MENU_NOT_FOUND(HttpServletResponse.SC_NOT_FOUND, "未找到该菜单"),

    /**
     * 不支持此Method
     */
    METHOD_NOT_SUPPORT(5005001, "METHOD不支持"), //

    /**
     * 业务逻辑错误
     */
    BIZ_ERR(5005010, "请求错误"),

    /**
     * 调用接口错误
     */
    API_ERR(5005099, "请求错误"),

    METHOD_ARGUMENT_NOT_VALID(1001001, "methodArgumentNotValid"), //

    URL_ARGUMENT_NOT_VALID(1001002, "urlArgumentNotValid"), //

    FILE_TOO_LARGE(1001003, "文件超过规定大小"); //

    private long value;

    private String desc;

    CommonError(long value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public long getValue() {
        return value;
    }

    @Override
    public String getDesc() {
        return desc;
    }
}
